home *** CD-ROM | disk | FTP | other *** search
GW-BASIC | 1997-03-24 | 3.6 KB | 139 lines |
- 10 'JCALC - "J-Calculator" - 24 MAR 97 rev.
- 20 IF EX$=""THEN EX$="EXIT"
- 30 CLS:KEY OFF
- 40 COLOR 7,0,1
- 50 U$="######.#"
- 60 UL$=STRING$(80,205)
- 70 GOTO 140
- 80 '
- 90 '.....format
- 100 LOCATE CSRLIN-1:PRINT SPC(7);
- 110 LOCATE CSRLIN,47:PRINT STRING$(7,".");USING U$;ZZ;
- 120 RETURN
- 130 '
- 140 '.....start
- 150 CLS:COLOR 15,2
- 160 PRINT " J-CALCULATOR (Complex Impedances)";
- 170 PRINT TAB(57)"by N. Sutherland ZL2APG ";
- 180 PRINT STRING$(80,32);
- 190 LOCATE CSRLIN-1,12
- 200 PRINT " edited and enhanced for HAMCALC by George Murphy VE3ERP"
- 210 COLOR 1,0:PRINT STRING$(80,223);:COLOR 7,0
- 220 GOSUB 960 'preface
- 230 COLOR 0,7:LOCATE 25,24
- 240 PRINT " Press 1 to continue or 0 to EXIT ";:COLOR 7,0
- 250 Z$=INKEY$:IF Z$=""THEN 250
- 260 IF Z$="0"THEN CLS:RUN EX$
- 270 IF Z$="1"THEN 300
- 280 GOTO 250
- 290 '
- 300 '.....inputs
- 310 VIEW PRINT 4 TO 24:CLS:VIEW PRINT:LOCATE 5
- 320 PRINT " 1st IMPEDANCE (Z1)"
- 330 INPUT " ENTER: Resistive Component....................(ohms)";A
- 340 ZZ=A:GOSUB 90:PRINT " -"
- 350 INPUT " ENTER: Reactive Component....................(ohms)";B
- 360 ZZ=B:GOSUB 90:PRINT " -"
- 370 IF B<0 THEN J$="-j"ELSE J$="+j"
- 380 B$=STR$(B):B$=RIGHT$(B$,LEN(B$)-1)
- 390 PRINT " Z1 Complex Impedance =";A;J$;B$;" -"
- 400 PRINT
- 410 PRINT " 2nd IMPEDANCE (Z2)
- 420 INPUT " ENTER: Resistive Component....................(ohms)";C
- 430 ZZ=C:GOSUB 90:PRINT " -"
- 440 INPUT " ENTER: Reactive Component....................(ohms)";D
- 450 ZZ=D:GOSUB 90:PRINT " -"
- 460 IF D<0 THEN J$="-j"ELSE J$="+j"
- 470 D$=STR$(D):D$=RIGHT$(D$,LEN(D$)-1)
- 480 PRINT " Z2 Complex Impedance =";C;J$;D$;" -"
- 490 LN=CSRLIN:PRINT UL$;
- 500 FOR I=1 TO 4:ON I GOSUB 660,720,780,840:NEXT I:GOTO 900
- 510 VIEW PRINT LN TO 24:CLS:VIEW PRINT:LOCATE LN+1
- 520 IF X<0 THEN J$=" -j"ELSE J$=" +j"
- 530 Z=INT(Z*10^3+0.5)/10^3
- 540 Z$=RIGHT$(STR$(Z),LEN(STR$(Z))-1)
- 550 IF ABS(Z)>0 AND ABS(Z)<1 THEN Z$="0"+Z$
- 560 IF Z<0 THEN Z$="-"+Z$ ELSE Z$=" "+Z$
- 570 X=INT(X*10^3+0.5)/10^3
- 580 X$=RIGHT$(STR$(X),LEN(STR$(X))-1)+" - "
- 590 IF ABS(X)>0 AND ABS(X)<1 THEN X$="0"+X$
- 600 PRINT TAB(9)"RESULT:";
- 610 PRINT " Z1 "R$" Z2";STRING$(30,".");
- 620 COLOR 0,7:PRINT " "Z$;J$;X$:LN=CSRLIN
- 630 COLOR 7,0
- 640 RETURN
- 650 '
- 660 '.....add
- 670 Z=A+C
- 680 X=B+D
- 690 R$="+"
- 700 GOTO 510
- 710 '
- 720 '.....subtract
- 730 Z=A-C
- 740 X=B-D
- 750 R$="-"
- 760 GOTO 510
- 770 '
- 780 '.....multiply
- 790 Z=(A*C)-(B*D)
- 800 X=(A*D)+(B*C)
- 810 R$="x"
- 820 GOTO 510
- 830 '
- 840 '.....divide
- 850 Z=((A*C)+(B*D))/(C^2+D^2)
- 860 X=((B*C)-(A*D))/(C^2+D^2)
- 870 R$="<UNK! {00F6}>"
- 880 GOTO 510
- 890 '
- 900 '.....end
- 910 PRINT :COLOR 0,7
- 920 LOCATE ,27:PRINT " Press any key to continue ";:COLOR 7,0
- 930 IF INKEY$=""THEN 930
- 940 GOTO 140
- 950 '
- 960 '.....preface
- 970 T=7
- 980 PRINT TAB(T);
- 990 PRINT " This program is intended as a j calculator for the addition,"
- 1000 PRINT TAB(T);
- 1010 PRINT "subtraction, multiplication and division of impedances in"
- 1020 PRINT TAB(T);
- 1030 PRINT "rectangular form (happily, without switching back and forth from"
- 1040 PRINT TAB(T);
- 1050 PRINT "rectangular to polar form). There is never any doubt which quadrant"
- 1060 PRINT TAB(T);
- 1070 PRINT "you are in."
- 1080 PRINT TAB(T);
- 1090 PRINT " For those of you who have not used operator j lately, +j rotates"
- 1100 PRINT TAB(T);
- 1110 PRINT "the impedance vector from the 3 o'clock initial position anti-"
- 1120 PRINT TAB(T);
- 1130 PRINT "clockwise 90<UNK! {00F8}> to the 12 o'clock position, and -j rotates from the"
- 1140 PRINT TAB(T);
- 1150 PRINT "3 o'clock initial position to 6 o'clock. As anyone can plainly see,"
- 1160 PRINT TAB(T);
- 1170 PRINT "+j is inductive and -j is capacitive. If this you cannot plainly"
- 1180 PRINT TAB(T);
- 1190 PRINT "see, don't bother about it; j has been used for 200 years without"
- 1200 PRINT TAB(T);
- 1210 PRINT "anyone knowing how it works."
- 1220 PRINT TAB(T);
- 1230 PRINT " It is no longer necessary to grapple with the Complex Algebra"
- 1240 PRINT TAB(T);
- 1250 PRINT "section of the 1997 ARRL HANDBOOK for RADIO AMATEURS (p.4.15), or"
- 1260 PRINT TAB(T);
- 1270 PRINT "other reference works of similar ilk. Use this program instead, to"
- 1280 PRINT TAB(T);
- 1290 PRINT "avoid boggling your mind."
- 1300 PRINT TAB(T);
- 1310 PRINT
- 1320 PRINT TAB(T);
- 1330 PRINT " The original version of this program was published in Vol. 70, #1"
- 1340 PRINT TAB(T);
- 1350 PRINT "of BREAK-IN, the official journal of the New Zealand Association"
- 1360 PRINT TAB(T);
- 1370 PRINT "of Radio Transmitters Inc.";
- 1380 RETURN
-